===, infix ⩶
ErrorsCollection

===, infix ⩶

Synthesised documentation from language/operators

From language/operators

See Original text in context

sub infix:<===>(AnyAny)

Value identity operator. Returns True if both arguments are the same object, disregarding any containerization.

my class A { };
my $a = A.new;
say $a === $a;              # OUTPUT: «True␤» 
say A.new === A.new;        # OUTPUT: «False␤» 
say A === A;                # OUTPUT: «True␤»

For value types, === behaves like eqv:

say 'a' === 'a';            # OUTPUT: «True␤» 
say 'a' === 'b';            # OUTPUT: «False␤» 
 
my $b = 'a';
say $b === 'a';             # OUTPUT: «True␤» 
 
# different types 
say 1 === 1.0;              # OUTPUT: «False␤»

=== uses the WHICH method to obtain the object identity.

If you want to create a class that should act as a value type, then that class must create an instance method WHICH, that should return a value type object that won't change for the lifetime of the object.

Since Rakudo version 2021.07, the Unicode character ⩶ is an alias for this operator.